<!DOCTYPE html>
<html>
<head>
<title>修改密码</title>
<@s.css 'oper/main.css' />
<@s.script ['jquery-1.7.2.min.js','jquery.form.js','sha1.js','jquery.validator.js','jquery.sdialog.js'] />
<script type='text/javascript'>
<!--
$(document).ready(function(){
	$('#f-form').validator({
	    msgHandler: function(msgs){
	        $.map(msgs, function(msg){
	        	showMessage(msg,"fail");
	        });
	    }
	});
	
	$('#ologinPwd').focus();
	var opwd="";
	var pwd="";
	var rpwd="";
	$('#f-form').ajaxForm({
		beforeSerialize:function(){
			opwd=$('#ologinPwd').val();
			pwd	=$('#loginPwd').val();
			rpwd=$('#rloginPwd').val();
			$('#ologinPwd').val(CryptoJS.SHA1(opwd));
			$('#loginPwd').val(CryptoJS.SHA1(pwd));
			$('#rloginPwd').val(CryptoJS.SHA1(rpwd));
		},
	    dataType:"json",
	    success: function(json) {
	    	if(json.state){
	    		$('#ologinPwd').val("");
	    		$('#loginPwd').val("");
	    		$('#rloginPwd').val("");
	    		$("#captcha").val("");
	    		$.sdialog({	
	    			title:"系统提示",
	    			content:json.message,
	    			ok:function(){
	    				window.top.location.href="/auth/logout.htm";
	    			}
	    		}).icon("success");
	    	}else{
	    		resetForm()
	    		showMessage(json.message,"fail");
	    		$('#captchaImage').attr('src','/security/captcha.htm?_='+Math.random());
	    	}
	    },
	    error:function(XMLHttpRequest, textStatus, errorThrown){
	    	resetForm();
			if(XMLHttpRequest.status==403)
				showMessage("没有权限访问","fail");
			else
				showMessage("服务忙，请稍后再试","fail");
	    }
	});
	function resetForm(){
		$('#ologinPwd').val(opwd);
		$('#loginPwd').val(pwd);
		$('#rloginPwd').val(rpwd);
	}
})

//-->
</script>
</head>
<body>
	<@s.message />
	<div class="m-form">
		<form name="f-form" id="f-form" action="<@s.url '/oper/pwd.do' />" method="post" >
			<div class="formitm">
				<label class="lab">原始密码：</label>
				<div class="ipt">
					<input type="password" name="ologinPwd" id="ologinPwd"  maxlength="16" data-rule="原始密码:required;password" placeholder="请输入原始密码"  />
				</div>
			</div>
			<div class="formitm">
				<label class="lab">新密码：</label>
				<div class="ipt">
					<input type="password" name="loginPwd" id="loginPwd"  maxlength="16" data-rule="新密码:required;password" placeholder="请输入新密码" />
				</div>
			</div>
			<div class="formitm">
				<label class="lab">确认密码：</label>
				<div class="ipt">
					<input type="password" name="rloginPwd" id="rloginPwd" maxlength="16"  data-rule="确认密码:required;password;match[loginPwd]" placeholder="请再次输入新密码"  />
				</div>
			</div>
			<div class="formitm">
				<label class="lab">验证码：</label>
				<div class="ipt">
					<input type="text" name="captcha" style="width: 80px;"  maxlength="5" id="captcha" data-rule="验证码:required;"  placeholder="验证码" />
					<a href="javascript:;" onclick="$('#captchaImage').attr('src','/security/captcha.htm?_='+Math.random());">看不清？换一张</a>
					<p class="tip">
						<@s.captcha />
					</p>
				</div>
			</div>
			<div class="formitm formitm-submit">
				<button class="u-btn" type="submit">修改密码</button>
			</div>
		</form>
		
	</div>
</body>
</html>